﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Portal.Xml.Utility;

namespace Portal.Systems.Model
{
    public class WorkflowDefMapRoleCls
    {
        public string WorkflowDefMapRoleId;
        public string frkWorkflowDefId;
        public string WorkflowRoleId;
        public string MapGroupRoleId;
        public string WorkflowRoleName;
    }

    public class WorkflowDefMapRoleParser
    {
        public static WorkflowDefMapRoleCls CreateInstance()
        {
            //tao 1 class trang....
            WorkflowDefMapRoleCls oWorkflowDefMapRoleCls = new WorkflowDefMapRoleCls();
            return oWorkflowDefMapRoleCls;
        }

        public static WorkflowDefMapRoleCls ParseFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            WorkflowDefMapRoleCls oWorkflowDefMapRoleCls = ParseFromDataRow(ds.Tables[0].Rows[0]);
            return oWorkflowDefMapRoleCls;
        }


        public static WorkflowDefMapRoleCls ParseFromDataRow(DataRow dr)
        {
            WorkflowDefMapRoleCls OWorkflowDefMapRoleCls = new WorkflowDefMapRoleCls();
            OWorkflowDefMapRoleCls.WorkflowDefMapRoleId = (string)dr["WorkflowDefMapRoleId"];
            OWorkflowDefMapRoleCls.frkWorkflowDefId = (string)dr["frkWorkflowDefId"];
            OWorkflowDefMapRoleCls.WorkflowRoleId = (string)dr["WorkflowRoleId"];
            if (dr["MapGroupRoleId"] != DBNull.Value)
            {
                OWorkflowDefMapRoleCls.MapGroupRoleId = (string)dr["MapGroupRoleId"];
            }
            if (dr["WorkflowRoleName"] != DBNull.Value)
            {
                OWorkflowDefMapRoleCls.WorkflowRoleName = (string)dr["WorkflowRoleName"];
            }

            return OWorkflowDefMapRoleCls;
        }

        public static WorkflowDefMapRoleCls[] ParseFromDataTable(DataTable dtTable)
        {
            WorkflowDefMapRoleCls[] WorkflowDefMapRoles = new WorkflowDefMapRoleCls[dtTable.Rows.Count];
            for (int iIndex = 0; iIndex < dtTable.Rows.Count; iIndex++)
            {
                WorkflowDefMapRoles[iIndex] = ParseFromDataRow(dtTable.Rows[iIndex]);
            }

            return WorkflowDefMapRoles;
        }
    }
}



